package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.data.DataResult;
import com.dongdongshop.data.ResponseStausEnum;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.service.SellerService;
import com.dongdongshop.util.PageBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @Description
 * @ClassName SellerController
 * @Author RC
 * @date 2020.12.12 21:32
 */
@Controller
@RequestMapping("seller")
public class SellerController {
    @Reference(timeout = 1000000,check = false)
    private SellerService sellerService;
    private static final Logger logger = LoggerFactory.getLogger(SellerController.class);

    @RequestMapping("getSellerList")
    @ResponseBody
    public DataResult getSellerList(@RequestParam(defaultValue = "1")Integer pageNumber, @RequestParam(defaultValue = "5")Integer pageSize,TbSeller tbSeller) {
        try {
            logger.info("进入商家信息查询方法");
            PageBean<TbSeller> specificationList = sellerService.getSellerList(pageNumber,pageSize,tbSeller);
            return DataResult.response(ResponseStausEnum.SUSSCESS).setData(specificationList);

        } catch (Exception e) {
            logger.info("查询失败", e);
            return DataResult.response(ResponseStausEnum.INTERNAL_SERVER_ERROR);
        }
    }
    @RequestMapping("getDetail/{sellerId}")
    @ResponseBody
    public DataResult getDetail(@PathVariable("sellerId")String sellerId) {
        try {
            logger.info("进入商家信息查询方法");
            TbSeller tbseller = sellerService.getInfoById(sellerId);
            return DataResult.response(ResponseStausEnum.SUSSCESS).setData(tbseller);

        } catch (Exception e) {
            logger.info("查询失败", e);
            return DataResult.response(ResponseStausEnum.INTERNAL_SERVER_ERROR);
        }
    }
    //审核
    @RequestMapping("getBunisee")
    @ResponseBody
    public DataResult getDetail(TbSeller tbSeller) {
        try {
            logger.info("进入商家信息查询方法");
            sellerService.getBunisee(tbSeller);
            return DataResult.response(ResponseStausEnum.SUSSCESS);

        } catch (Exception e) {
            logger.info("查询失败", e);
            return DataResult.response(ResponseStausEnum.INTERNAL_SERVER_ERROR);
        }
    }

}
